package com.liu.network.httpclient;

import java.io.UnsupportedEncodingException;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class testHttp {
	public static void main(String[] args) throws UnsupportedEncodingException {
		
		CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(HttpClientUtil.getRequestConfig(300)).build();

	//	Object resCode = HttpClientUtil.doPost(httpClient,"http://192.168.2.28:8080/DataInterface/api/report","{\"reportName\":\"171251898_report940\",\"reportID\":null,\"reportType\":1,\"syntStatType\":null,\"statisticType\":1,\"linkID\":85,\"topNumber\":null,\"statCont\":\"1\",\"statUnit\":\"1\",\"timeSize\":null,\"startTime\":1512382080000,\"endTime\":1512468480000,\"cycleReport\":null,\"email\":null,\"isModule\":null,\"operatorID\":null,\"configTime\":null,\"operatorName\":null,\"netProtocol\":null,\"orderWay\":null,\"multiDimension\":[{\"id\":null,\"reportID\":null,\"appGroupId\":27,\"appGroupName\":\"程序开发\",\"appId\":4,\"appName\":\"cvs\",\"userId\":91,\"userName\":\"A1039\",\"userGroupId\":4,\"userGroupName\":\"A小组\",\"externalId\":null,\"externalIdName\":null,\"regionId\":1,\"regionName\":\"北京\",\"carrierId\":null,\"carrierName\":null,\"scientificId\":null,\"scientificName\":null,\"virtualLinkId\":null,\"virtualLinkName\":null,\"topn\":null,\"showModels\":\"appGroup|app|userGroup|user|regionInternal\"},{\"id\":null,\"reportID\":null,\"appGroupId\":-1,\"appGroupName\":\"\",\"appId\":null,\"appName\":null,\"userId\":null,\"userName\":null,\"userGroupId\":null,\"userGroupName\":null,\"externalId\":null,\"externalIdName\":null,\"regionId\":null,\"regionName\":null,\"carrierId\":null,\"carrierName\":null,\"scientificId\":null,\"scientificName\":null,\"virtualLinkId\":null,\"virtualLinkName\":null,\"topn\":\"10\",\"showModels\":\"appGroup\"}]}","application/json", "utf-8");
	//	Object resCode = HttpClientUtil.doPost(httpClient,"http://127.0.0.1:8080/DataInterface/api/report","在","application/json", "utf-8");

		ObjectMapper jsonMap = new ObjectMapper();
		String yy = null;
        try {
            yy = jsonMap.writeValueAsString("");
        } catch (JsonProcessingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
		Object resCode = HttpClientUtil.doPost(httpClient,"http://127.0.0.1:8080/DataInterface/api/reports/search",yy,"application/json", "utf-8");
		System.out.println(resCode);
		//Object resCode1 = HttpClientUtil.doGet(httpClient, "http://192.168.2.28:8080/DataInterface/api/reports");
       //System.out.println(resCode1);
	  /* CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(HttpClientUtil.getRequestConfig(300)).build();   
        Object resCode = HttpClientUtil.doGet(httpClient, "http://192.168.2.28:8080/DataInterface/api/reports");
        //转化为list
        List<HighReport> list2=(List<HighReport>)JSONArray.toList(JSONArray.fromObject(resCode), HighReport.class);
        System.out.println(list2);*/
	   /* CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(HttpClientUtil.getRequestConfig(300)).build();   
        Object resCode = HttpClientUtil.doDelete(httpClient, "http://192.168.2.28:8080/DataInterface/api/reports/1,2,3");
        System.out.println(resCode);*/
	}
}
